package master;

/**
 * @author chenyw
 * @date 2022/9/5 15:34
 */
public class M242isAnagram {
    public boolean isAnagram(String s, String t) {
        if (s.length() != t.length()) {
            return false;
        }
        int[] arrA = new int[26];
        int[] arrB = new int[26];
        for (int i = 0; i < s.length(); i++) {
            char a = s.charAt(i);
            char b = t.charAt(i);
            arrA[a - 'a']++;
            arrB[a-'a']++;
        }
        for (int i = 0; i < 26; i++) {
            if (arrA[i] != arrB[i]) {
                return false;
            }
        }
        return true;
    }
}
